package com.interview.item.javabase.stringdemo;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @Author:zxh
 * @Description:
 * @Date: 2020/3/23
 * @Modified By:
 */
public class StringMethod {
    private Logger log = LoggerFactory.getLogger(StringMethod.class);

    public void method() {

        /*
        // String str = new String();
        String str = "www.runoob.com";
        String str2 = "www.runoob.COM123";
        String str3 = "    www.runoob.c  om  ";
        char c = str.charAt(0);
        log.info("charAt:返回指定索引处的字符：{}", c);

        str.codePointAt(2);
        str.codePointBefore(2);
        str.codePointCount(1, 2);

        int to = str.compareTo(str2);
        log.info("compareTo:比较对象：{}", to);

        int toIgnoreCase = str.compareToIgnoreCase(str2);
        log.info("compareToIgnoreCase:按字典顺序比较字符串/不区分大小写：{}", toIgnoreCase);

        str.contains("");
        String concat = str.concat(str2);
        log.info("concat:将指定字符串合并到字符串结尾：{}", concat);

        StringBuffer stringBuffer = new StringBuffer("www.runoob.com");
        boolean b = str.contentEquals(stringBuffer);
        log.info("contentEquals:将此字符串与指定的StringBuffer比较：{}", b);
        String.format(str, 3);

        byte[] bytes = str.getBytes();
        log.info("getBytes():将使用平台默认的字符集将string编码为byte序列，并将结果存储到一个新的byte数组中：{}", bytes);

        //str.getChars();
        str.hashCode();

        //c-99
        int indexOf = str.indexOf(99);
        int indexOf1 = str.indexOf("w");
        int indexOf2 = str.indexOf("w", 1);
        log.info("返回指定字符在此字符串中第一次出现处的索引：{}: {}: {}", indexOf, indexOf1, indexOf2);


        String intern = str.intern();
        log.info("intern:返回字符串规范化表现形式：{}", intern);

        boolean empty = str.isEmpty();
        log.info("isEmpty:当且仅当lenght为0时返回true：{}", empty);

        int indexOf3 = str.lastIndexOf(3);
        int indexOf5 = str.lastIndexOf("o");
        int indexOf4 = str.lastIndexOf("o", 9);
        log.info("lastIndexOf:返回指定字符串在此字符串中最后出现的索引：{}: {}:{}", indexOf3, indexOf4, indexOf5);

        str.length();
        str.matches("");
        str.offsetByCodePoints(3, 4);
        //str.regionMatches();

        String replace = str.replace("w", "taobao");
        log.info("replace:通过newChar替换此字符串中出现的所有oldChar:{}", replace);
        String taobao = str.replaceAll("(.*)www(.*)", "taobao");
        log.info("replaceAll:替换字符串所有匹配给定的正则表达式的子字符串：{}", taobao);
        String taobao1 = str.replaceFirst("(.*)oo(.*)", "taobao");
        log.info("replaceFirst:替换字符串第一个匹配给定的正则表达式的子字符串:{}", taobao1);

        //str.split();
        str.startsWith("");
        str.endsWith("");
        str.subSequence(1, 2);

        String substring = str.substring(1, 4);
        String substring1 = str.substring(5);
        log.info("substring:返回一个新的字符串，它是此字符串的一个子字符串：{}: {}",substring,substring1);

        char[] chars = str.toCharArray();
        log.info("toCharArray:将此字符转为字符数组：{}", chars);

        String s2 = str2.toLowerCase();
        log.info("toLowerCase:将所有的字符转换为小写：{}", s2);
        String s3 = str2.toUpperCase();
        log.info("toUpperCase:将所有字符转换为大写：{}", s3);

        String trim = str3.trim();
        log.info("trime:返回字符串副本，忽略前导空白和后导空白：{}",trim);
        String s = String.valueOf(true);
        String s1 = String.valueOf(str);
        log.info("valueOf将给定的data type，输出字符串表示形式：{}: {}", s, s1);
*/

    }

    public static void main(String[] args) {
        StringMethod stringMethod = new StringMethod();
        stringMethod.method();
    }
}
